# 保持宽高比的情况下，将frame尺寸缩放到window中
def KeepAspectScale(frameWidth, frameHeight, windowWidth, windowHeight):
    
    PlaybackSize = [0, 0]
    scaleBy = "width"
    
    if frameWidth / frameHeight >= windowWidth / windowHeight:
        # 按宽度缩放
        PlaybackSize[0] = windowWidth
        PlaybackSize[1] = frameHeight * windowWidth / frameWidth
        
    else:
        # 按高度缩放        
        scaleBy = "height"
        PlaybackSize[1] = windowHeight
        PlaybackSize[0] = frameWidth * windowHeight / frameHeight
        
    return PlaybackSize, scaleBy